/*
 * gios.h
 * General/Input/Output functions for uPL0c.
 *
 * Copyright 2024 dh33ex <dh33ex@riseup.net>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301, USA or visit <http://www.gnu.org/licenses/>.
 *
 *
 */

#ifndef GIOS_H
#define GIOS_H

#define ID_LEN          16

/* a structure that will contain variables related to the compiler */
typedef struct {
    int error;          /* error status */

    /* current token */
    int token;          /* token type */
    int val;            /* number (if TOK_NUMBER) */
    char id[ID_LEN];    /* identifier (if TOK_IDENT) */
} Compiler;

extern Compiler compiler;

/* global functions */
int read_from(char *filename);
int write_to(char *filename);
void end_write(void);

/* functions of writing the output file */
void write_bin(void);
void write_code(void);
void write_txt(void);

void print_error(char *msg);
void print_note(char *msg);

int get_ch(void);
void unget_ch(int ch);

#endif
